<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<ui:composition>
    <p:panel id="pnlBankAccount" header="Contas bancárias" widgetVar="panelBankAccount">

        <p:dataTable id="dataTableBankAccount" var="bankAccount" value="#{financesDashboardMBean.listBankAccount}" rowKey="#{bankAccount.pkBankAccount}" selection="#{financesDashboardMBean.selectedBankAccount}"
                     selectionMode="single" update="panel_edit_bank_account" paginator="true" rows="10" paginatorPosition="top">
            <p:column width="200" rendered="#{logonMBean.login.loginRulesView.root}">
                <f:facet name="header">Empresa</f:facet>
                <h:outputText value="#{bankAccount.company.name}"/>
            </p:column>

            <p:column>
                <f:facet name="header">Conta bancária</f:facet>
                <h:outputText value="#{bankAccount.name}"/>
            </p:column>

            <p:column>
                <f:facet name="header">Saldo SMS</f:facet>
                <h:outputText value="#{bankAccount.quantitySmsBuyed}"/>
            </p:column>

            <p:column rendered="#{logonMBean.login.loginRulesView.root}">
                <f:facet name="header">Saldo Bancário</f:facet>
                <h:outputText value="#{bankAccount.balance}">
                    <f:convertNumber type="currency" currencySymbol="R$" locale="pt" minFractionDigits="2" maxFractionDigits="2" />
                </h:outputText>
            </p:column>
        </p:dataTable>

        <p:commandButton id="btnCreateBankAccount" value="Criar" styleClass="btn" onclick="create_bank_account.show()" />
        <p:commandButton id="btnEditBankAccount" value="Editar" styleClass="btn" onclick="edit_bank_account.show()" />
        <p:commandButton id="btnRemoveBankAccount" value="Apagar" styleClass="btn" actionListener="#{financesDashboardMBean.removeBankAccount}" update="dataTableBankAccount, dataTableCredit"/>
    </p:panel>
</ui:composition>
</html>